//
//  LOLSkillsCollectionCell.m
//  LOLXXbox
//
//  Created by dllo on 16/2/26.
//  Copyright © 2016年 Grasstrio. All rights reserved.
//

#import "LOLSkillsCollectionCell.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>
@implementation LOLSkillsCollectionCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageViews = [[UIImageView alloc] init];
        [self addSubview:self.imageViews];
        
        self.label = [[UILabel alloc] init];
        self.label.font = [UIFont systemFontOfSize:15];
        self.label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.label];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    [self.imageViews mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(5);
        make.left.equalTo(self.contentView).offset(5);
        make.right.equalTo(self.contentView).offset(-5);
        make.bottom.equalTo(self.contentView).offset(-30);
    }];
    
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(-5);
        make.left.equalTo(self.contentView).offset(5);
        make.right.equalTo(self.contentView).offset(-5);
        make.top.equalTo(self.imageViews.mas_bottom).offset(5);
    }];
    
}
- (void)setSkillModel:(LOLSkillsModel *)skillModel{
    _skillModel = skillModel;
    self.label.text = _skillModel.name;
    [self.imageViews sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/spells/png/%@.png", skillModel.myId]]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
